<?php
require_once __DIR__ . '/vendor/autoload.php';

$worker=new \Workerman\Worker('tcp://0.0.0.0:9200');
$f=fopen(__DIR__.'/App/demo/20.h264','r');
$worker->onConnect = function ($con)use($f) {
    var_dump("hello con");
    while(!feof($f)){
        $con->send(fgets($f));
        usleep(1000);
    }
    $con->close();
};

$worker->onMessage=function($con,$msg)use($f){
    var_dump("hello msg");
      while(!feof($f)){
          $con->send(fgets($f));
          usleep(1000);
      }
      $con->close();
};



if (!defined('GLOBAL_START')) {
    \Workerman\Worker::runAll();
}